package org.poker.prophecy.simulation.gui;

import java.awt.Dimension;
import java.awt.GridBagLayout;
import javax.swing.JPanel;
import java.awt.GridLayout;
import javax.swing.JLabel;

import org.poker.prophecy.ImagesManager;
import org.poker.prophecy.core.Card;

public class TableBoard extends JPanel {

	private static final long serialVersionUID = 1L;
	private JLabel c0 = null;
	private JLabel c1 = null;
	private JLabel c2 = null;
	private JLabel c3 = null;
	private JLabel c4 = null;

	/**
	 * This is the default constructor
	 */
	public TableBoard() {
		super();
		initialize();
	}

	/**
	 * This method initializes this
	 * 
	 * @return void
	 */
	private void initialize() {
		c4 = new JLabel();
		c4.setPreferredSize(new Dimension(45, 63));
		c3 = new JLabel();
		c3.setPreferredSize(new Dimension(45, 63));
		c2 = new JLabel();
		c2.setPreferredSize(new Dimension(45, 63));
		c1 = new JLabel();
		c1.setPreferredSize(new Dimension(45, 63));
		c0 = new JLabel();
		c0.setPreferredSize(new Dimension(45, 63));
		GridLayout gridLayout = new GridLayout();
		gridLayout.setRows(1);
		gridLayout.setHgap(5);
		gridLayout.setColumns(5);
		this.setLayout(gridLayout);
		this.setSize(245, 63);
		this.add(c1, null);
		this.add(c0, null);
		this.add(c2, null);
		this.add(c3, null);
		this.add(c4, null);
	}

	
	
	public void setCard(int pos, Card c){
		switch(pos){
		case 0:
			this.c0.setIcon(ImagesManager.getJpgImageIconForCard(c));
			break;
		case 1:
			this.c1.setIcon(ImagesManager.getJpgImageIconForCard(c));
			break;
		case 2:
			this.c2.setIcon(ImagesManager.getJpgImageIconForCard(c));
			break;
		case 3:
			this.c3.setIcon(ImagesManager.getJpgImageIconForCard(c));
			break;
		case 4:
			this.c4.setIcon(ImagesManager.getJpgImageIconForCard(c));
			break;
		}
		
	}
	
	public void clearBoard(){
		this.c0.setIcon(null);
		this.c1.setIcon(null);
		this.c2.setIcon(null);
		this.c3.setIcon(null);
		this.c4.setIcon(null);
	}	
		

	
	
	
}
